package sy.bo;

import java.util.List;

import org.nutz.json.Json;

import sy.po.Resource;
import sy.po.User;

/**
 * 这个类用于在session中存储用户登陆后的信息，为了便于管理，系统中所有要向session中存储信息的时候，都存入到这个类中
 * 
 * @author 孙宇
 *
 */
public class SessionInfo implements java.io.Serializable {

	public static final String SESSIONINFONAME = "sessionInfo";// session中存入的名称

	private User user;// 保存用户信息

	private List<Resource> resources;// 用户能访问的资源集合

	public SessionInfo() {

	}

	public SessionInfo(User user) {
		this.user = user;
	}

	public SessionInfo(User user, List<Resource> resources) {
		this.user = user;
		this.resources = resources;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<Resource> getResources() {
		return resources;
	}

	public void setResources(List<Resource> resources) {
		this.resources = resources;
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("用户：\r\n");
		str.append(Json.toJson(this.getUser()));
		str.append("\r\n");
		str.append("可访问资源：\r\n");
		str.append(Json.toJson(this.getResources()));
		return str.toString();
	}

}
